package com.kim.common;

import com.kim.common.Snowflakes.IdGenerateUtils;
import com.kim.common.Snowflakes.key.SnowflakeIdWorker;
import com.kim.common.exception.GlobalExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.Order;

import java.util.ArrayList;
import java.util.List;

/**
 * @author KimWu
 * @date 2020/6/8 11:32
 * @Description ：
 */
@Slf4j
@Import({
        GlobalExceptionHandler.class
})
public class KimCommonAutoConfiguration {
    public KimCommonAutoConfiguration(){
        final List<String> DESC = new ArrayList<String>(){
            {
                add("注入全局异常处理");
            }
        };
        log.info(DESC.toString());
    }

    @Bean
    @Order
    @ConditionalOnMissingBean
    public SnowflakeIdWorker snowflakeIdWorker() {
        log.info("注入雪花算法生成器");
        return IdGenerateUtils.getSnowflakeIdWorker();
    }
}
